import axios from '@/libs/api.request'

export const getAttrAndValueByCondition = (condition) => {
  return axios.request({
    url:  'attribute/list',
    params: condition,
    method: 'get'
  })
}

export const getattributeByPid = (pid) => {
  return axios.request({
    url:  'attribute/sons',
    params: pid,
    method: 'get'
  })
}

export const getAttributeById = (id) => {
  return axios.request({
    url:  'attribute/'+id,
    method: 'get'
  })
}

export const checkattributeCode = (code) => {
  return axios.request({
    url:  'attribute/code/check',
    params: {
      code
    },
    method: 'get'
  })
}

export const addAttributeValue = (value) => {
	return axios.request({
		url:'attribute/value/add',
		data:value,
		method:'post'
	})
}

export const getValuesByAttrId = (aid) => {
  return axios.request({
    url:  'attribute/value/list',
    params: {'aid':aid},
    method: 'get'
  })
}

export const addAttribute = (attribute) => {
  return axios.request({
    url:  'attribute/add',
    data: attribute,
    method: 'post'
  })
}

export const updateAttribute = (attribute) => {
  return axios.request({
    url:  'attribute/update',
    data: attribute,
    method: 'put'
  })
}

export const deleteAttributeByIds = (ids) => {
  return axios.request({
    url:  'attribute',
		params:{ids},
    method: 'delete'
  })
}